# Contributor: Nathan Johnson <nathan@nathanjohnson.info>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php8-pecl-couchbase
_extname=couchbase
pkgver=4.0.0
pkgrel=0
pkgdesc="PHP 8.0 extension for Couchbase - PECL"
url="https://pecl.php.net/package/couchbase"
arch="all !riscv64" # ftbfs
license="Apache-2.0"
depends="php8-pecl-igbinary"
makedepends="php8-dev openssl-dev linux-headers chrpath cmake ccache"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$pkgver.tgz
	cmake-build-type.patch
	cmake-fix-cache.patch
	"
builddir="$srcdir/$_extname-$pkgver"

build() {
	phpize8
	./configure --prefix=/usr --with-php-config=php-config8
	make
}

check() {
	# require couchbase and phpunit
	php8 -d extension="$builddir"/modules/$_extname.so --ri $_extname
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	chrpath -d "$pkgdir"/usr/lib/php8/modules/$_extname.so
	chrpath -d "$pkgdir"/usr/lib/php8/modules/libcouchbase_php_core.so

	local _confdir="$pkgdir"/etc/php8/conf.d
	mkdir -p $_confdir
	echo "extension=$_extname" > $_confdir/$_extname.ini
}

sha512sums="
5a2571c18f4d0fd46239eed10b77271260352bda38ad5695db65dc7a47f14bab00cfa4a98c646544f7e2865939ae5f981edbc6f63216a0ee537a5a9666198f1e  php-pecl-couchbase-4.0.0.tgz
e61589d1a17968a4980e41a79351d5fa26dc6ecfca8430f87304bd309e1d738eb026b0206694069acce6cf8992a3701f9d0ebe372050a178087c5bee04166e13  cmake-build-type.patch
56c0ea44a55aa5622adbd3e5de435c30696897474f102a62882a54bbb75b8bbf3e9b055766fc8db68623bc7e2561e9b180bbd7de3b8e4cf8aad0853dce3f7b3a  cmake-fix-cache.patch
"
